import { fliterDataWrapper } from 'common/js/table'

export const columns = (that) => {

  return [
    {
      key: 'stationCode',
      align: 'center',
      width: 120,
      title: '站点编码',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'stationCode')
      }
    },
    {
      key: 'imei',
      align: 'center',
      width: 135,
      title: '设备编码',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'imei')
      }
    },
    {
      key: 'stationName',
      align: 'center',
      title: '站点名称',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'stationName')
      }
    },
    {
      key: 'deptName',
      title: '所属镇街',
      align: 'center',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'deptName')
      }
    },
    {
      key: 'realDl1',
      align: 'center',
      title: '电流1#',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'realDl1')
      }
    },
    {
      key: 'realDl1State',
      align: 'center',
      title: '运行状态1#',
      render: (h, params) => {
        const { row } = params
        const status = row.realDl1State
        let color = '#19be6b' // 默认绿色

        // 根据状态设置不同颜色
        if (status === '停止') {
          color = '#ed4014'
        } 

        return h('span', { style: { color } }, row.realDl1State || '--')
      }
    },
    {
      key: 'realDl2',
      align: 'center',
      title: '电流2#',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'realDl2')
      }
    },
    {
      key: 'realDl2State',
      align: 'center',
      title: '运行状态2#',
      render: (h, params) => {
        const { row } = params
        const status = row.realDl2State
        let color = '#19be6b' // 默认绿色

        // 根据状态设置不同颜色
        if (status === '停止') {
          color = '#ed4014'
        } 

        return h('span', { style: { color } }, row.realDl2State || '--')
      }
    },
    {
      key: 'deviceStatus',
      align: 'center',
      title: '设备状态',
      render: (h, params) => {
        const { row } = params
        const status = row.deviceStatus
        let color = '#19be6b' // 默认绿色

        // 根据状态设置不同颜色
        if (status === '离线') {
          color = '#ed4014'
        } 

        return h('span', { style: { color } }, row.deviceStatus || '--')
      }
    },
    {
      key: 'monitorTime',
      align: 'center',
      title: '监测时间',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'monitorTime')
      }
    },
    {
      key: 'createTime',
      align: 'center',
      title: '数据采集时间',
      render: (h, params) => {
        const { row } = params

        return fliterDataWrapper(h, row, 'createTime')
      }
    },
  ]
}
